﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true"
    CodeBehind="Index.aspx.cs" Inherits="WebChamCong.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_title" runat="server">
    Hello
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content_header" runat="server">
    Thiết lập công nhân viên phòng ban
    <script type="text/javascript">
        $(document).ready(function () {
            var $i = -1;
            $('.show').click(function () {
                $i = $(this).attr('id');
                $('.appear1').hide();
                $('.appear2').hide();
                $('.appear3').hide();
                $("#a_" + $i).removeAttr('style');
                $("#a_" + $i).attr('style', 'margin-left:40px;');
                $("#fix_time").show("slow");
                $t1 = $("#temp_tin").val();
                $t2 = $("#temp_tout").val();
                $("#time3").val($t1);
                $("#time4").val($t2);
                $.post("Index.aspx", { 'GroupShift': $('input[name=GroupShift]:checked').val() }, function () { });
            });

            $('.appear1').click(function () {
                $('.appear1').hide();
                $("#fix_time").show();
                $i = $(this).attr('title');
                $("#a1_" + $i).removeAttr('style');
                $("#a2_" + $i).removeAttr('style');
                $("#time3").removeAttr("disabled");
                $("#time4").removeAttr("disabled");
                $("#a1_" + $i).attr('style', 'text-align: center; margin-left:10px');
                $("#a2_" + $i).attr('style', 'text-align: center; margin-left:10px');

            });
            $('.appear2').click(function () {
                $('.appear2').hide();
                $('.appear3').hide();
                $("#a_" + $i).show();
                PageMethod("ClickMe", ["temp_UserID", $("#temp_UserID").val(), "temp_Day", $("#temp_Day").val(), "time3", $("#time3").val(), "time4", $("#time4").val()], succeededAjaxFn);
            });

            $('.appear3').click(function () {
                $('.appear1').hide();
                $('.appear2').hide();
                $('.appear3').hide();
                $("#time3").attr('disabled', 'disabled');
                $("#time4").attr('disabled', 'disabled');
            });

            var succeededAjaxFn = function (result) {
                alert("You have just updated these information: UserID: " + $("#temp_UserID").val() + ", exceptional day: " + $("#temp_Day").val() + ", from: " + $("#time3").val() + ", to: " + $("#time4").val());
            }

          
        });
    </script>
    <!--script auto fix time for timepicker-->
    <script type="text/javascript">
        jQuery(function () {
            $("#time3").timePicker();
            $("#time4").timePicker();

            // Store time used by duration.
            //            var oldTime = $.timePicker("#time3").getTime();

            //            // Keep the duration between the two inputs.
            //            $("#time3").change(function () {
            //                if ($("#time4").val()) { // Only update when second input has a value.
            //                    // Calculate duration.
            //                    var duration = ($.timePicker("#time4").getTime() - oldTime);
            //                    var time = $.timePicker("#time3").getTime();
            //                    // Calculate and update the time in the second input.
            //                    $.timePicker("#time4").setTime(new Date(time.getTime() + duration));
            //                    oldTime = time;
            //                }
            //            });

            //            // Validate.
            //            $("#time4").change(function () {
            //                if ($.timePicker("#time3").getTime() > $.timePicker(this).getTime()) {
            //                    $(this).addClass("error");
            //                }
            //                else {
            //                    $(this).removeClass("error");
            //                }
            //            });

        });
    </script>
    <asp:Label ID="lb_departName" runat="server" Text="Label"></asp:Label>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <p>
                Chọn tháng :
                <asp:DropDownList ID="ddl_month" runat="server" OnSelectedIndexChanged="ddl_month_SelectedIndexChanged"
                    AutoPostBack="True">
                </asp:DropDownList>
                &nbsp; Chọn năm :
                <asp:DropDownList ID="ddl_year" runat="server" OnSelectedIndexChanged="ddl_year_SelectedIndexChanged"
                    AutoPostBack="True">
                </asp:DropDownList>
                &nbsp; Báo Cáo :
                <asp:Button ID="Button1" runat="server" Text="Xuất báo cáo thiết lập công" OnClick="Button1_Click" />
            </p>
            <p>
                Tổng số nhân viên hiện tại : (<asp:Label ID="lb_numEmps" runat="server" Text="0"></asp:Label>)
            </p>
            <asp:Button ID="BtnRefresh" runat="server" Text="Refresh" OnClick="Refresh_OnClick" />
            <p>
                <asp:Button ID="btn_CreateSchedule" runat="server" Text="Create Schedule" Visible="false"
                    OnClick="CreateSchedule_OnClick" />
            </p>
            <p>
                <asp:GridView ID="gv_listUsers" runat="server" Width="100%" OnRowDataBound="gv_listUsers_RowDataBound"
                    OnRowCommand="gv_listUsers_RowCommand" EmptyDataText="List empty" AllowPaging="True"
                    AutoGenerateColumns="False" OnPageIndexChanging="gv_listUsers_PageIndexChanging"
                    OnSelectedIndexChanged="gv_listUsers_SelectedIndexChanged">
                </asp:GridView>
            </p>
            <asp:Panel ID="pn_listShift" runat="server" CssClass="modalPopup">
                <div >
                    <asp:HiddenField ID="hf_u" runat="server" />
                    <asp:HiddenField ID="hf_s" runat="server" />
                    <asp:HiddenField ID="hf_d" runat="server" />
                    <asp:HiddenField ID="hf_m" runat="server" />
                    <asp:HiddenField ID="hf_y" runat="server" />
                    <asp:HiddenField ID="hf_ti" runat="server" />
                    <asp:HiddenField ID="hf_to" runat="server" />
                    <p>
                        <div id="fix_time" style="display: none" class="fixed_time">
                            <asp:Label ID="lbl_time1" runat="server" Text="Từ: "></asp:Label>
                            <input type="text" disabled="disabled" id="time3" size="6" />
                            <asp:Label ID="lbl_time2" runat="server" Text="Đến: "></asp:Label>
                            <input type="text" disabled="disabled" id="time4" size="6" />
                        </div>
                        <div id="div_temp" runat="server">
                            <input type="text" runat="server" style="display: none" id="temp_Day" size="6" />
                            <input type="text" runat="server" style="display: none" id="temp_UserID" size="6" />
                            <input type="text" runat="server" style="display: none" id="temp_tin" size="6" />
                            <input type="text" runat="server" style="display: none" id="temp_tout" size="6" />
                        </div>
                        <div id="div_list" runat="server">
                        </div>
                        <p id="p_footer" runat="server" style="text-align: center;">
                            <asp:Button ID="OkButton" runat="server" OnClick="OkButton_OnClick" Text="OK" />
                            <asp:Button ID="CancelButton" runat="server" Text="Cancel" />
                        </p>
                    </p>
                </div>
            </asp:Panel>
            <asp:LinkButton ID="LinkButton1" runat="server" Enabled="false">Version :1.0.1</asp:LinkButton>
            <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1"
                PopupControlID="pn_listShift" BackgroundCssClass="modalBackground" CancelControlID="CancelButton">
            </asp:ModalPopupExtender>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="Button1" />
            <asp:PostBackTrigger ControlID="gv_listUsers" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
